// transmission-remote-dotnet
// https://code.google.com/p/transmission-remote-dotnet-magnet-friendly-edition/
// Copyright (C) 2009  Alan F, 2013-2014  __alex
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.Windows.Forms;
using Jayrock.Json;

namespace TransmissionRemoteDotnet.Comparers
{
    public class ListViewItemDecimalComparer : IComparer
    {
        int columnIndex;

        public ListViewItemDecimalComparer(int columnIndex)
        {
            this.columnIndex = columnIndex;
        }

        int IComparer.Compare(object x, object y)
        {
            ListViewItem lx = (ListViewItem)x;
            ListViewItem ly = (ListViewItem)y;
            decimal nx = (decimal)lx.SubItems[columnIndex].Tag;
            decimal ny = (decimal)ly.SubItems[columnIndex].Tag;
            return nx.CompareTo(ny);
        }
    }
}
